SET sql-client.execution.result-mode=TABLEAU;
-- 执行命令： sql-client.sh -f flink_host_zzdetail-test.q

CREATE TABLE hdp_hism_idea_raw_host_zzdetail (
  content STRING
) WITH (
  'connector' = 'kafka',
  'topic' = 'host_zzdetail',
  'properties.bootstrap.servers' = 'node101:9092',
  'format' = 'raw'
);

CREATE FUNCTION split_udf AS 'com.bigdata.udf.SplitUDF';
CREATE FUNCTION split_func AS 'com.bigdata.udtf.SplitFunction';

-- 解析出来对应的单行内容
select
  log_ts,
  cast(log_content_len as int) as content_len,
  char_length(log_content_info) as content_len2,
  item
from (
  select
    arr[1] as log_ts, substring(arr[11],1,5) as log_content_len, substring(arr[11],7) as log_content_info
  from (
    select split_udf(content,'\$\$') as arr
    from hdp_hism_idea_raw_host_zzdetail
  ) a
) b, lateral table(split_func(log_content_info, '##')) as t(item)




